
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>微信支付API接口 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="micropay.html" />
    
    
    <link rel="prev" href="wxapi.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../../">
            
                <a href="../../../">
            
                    
                    项目导航
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../../contact.html">
            
                <a href="../../contact.html">
            
                    
                    联系方式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../../study.html">
            
                <a href="../../study.html">
            
                    
                    学习资料
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../../gitchat.html">
            
                <a href="../../gitchat.html">
            
                    
                    GitChat交流
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../../blog/">
            
                <a href="../../blog/">
            
                    
                    我的博客
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../../opensource/">
            
                <a href="../../opensource/">
            
                    
                    开源项目
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../../opensource/IJPay.html">
            
                <a href="../../opensource/IJPay.html">
            
                    
                    What is a IJPay?
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../../opensource/JPay.html">
            
                <a href="../../opensource/JPay.html">
            
                    
                    Android支付SDK-JPay
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../../opensource/weixin_guide.html">
            
                <a href="../../opensource/weixin_guide.html">
            
                    
                    极速开发微信公众号
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../">
            
                <a href="../">
            
                    
                    IJPay 文档
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../../IJPay-Demo.html">
            
                <a href="../../IJPay-Demo.html">
            
                    
                    IJPay-Demo
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../alipay/">
            
                <a href="../alipay/">
            
                    
                    支付宝支付
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.2.1" data-path="../alipay/alipay-config.html">
            
                <a href="../alipay/alipay-config.html">
            
                    
                    配置应用环境
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2.2" data-path="../alipay/alipay-init.html">
            
                <a href="../alipay/alipay-init.html">
            
                    
                    IJPay 支付宝初始化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2.3" data-path="../alipay/alipay-wap.html">
            
                <a href="../alipay/alipay-wap.html">
            
                    
                    支付宝手机网站支付
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2.4" data-path="../alipay/alipay-pc.html">
            
                <a href="../alipay/alipay-pc.html">
            
                    
                    支付宝电脑网站支付
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2.5" data-path="../alipay/alipay-offline.html">
            
                <a href="../alipay/alipay-offline.html">
            
                    
                    当面付
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.2.5.1" data-path="../alipay/alipay-offline/alipay-qrPay.html">
            
                <a href="../alipay/alipay-offline/alipay-qrPay.html">
            
                    
                    支付宝扫码支付
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2.5.2" data-path="../alipay/alipay-offline/alipay-barPay.html">
            
                <a href="../alipay/alipay-offline/alipay-barPay.html">
            
                    
                    支付宝条码支付
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2.5.3" data-path="../alipay/alipay-offline/alipay-wavePay.html">
            
                <a href="../alipay/alipay-offline/alipay-wavePay.html">
            
                    
                    支付宝声波支付
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7.2.6" data-path="../alipay/alipay-coupon.html">
            
                <a href="../alipay/alipay-coupon.html">
            
                    
                    支付宝红包
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2.7" data-path="../alipay/alipay-transfer.html">
            
                <a href="../alipay/alipay-transfer.html">
            
                    
                    支付宝提现
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2.8" data-path="../alipay/alipay-app.html">
            
                <a href="../alipay/alipay-app.html">
            
                    
                    支付宝APP支付
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2.9" data-path="../alipay/alipay-notify.html">
            
                <a href="../alipay/alipay-notify.html">
            
                    
                    支付宝服务端异步通知
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2.10" data-path="../alipay/alipay-api.html">
            
                <a href="../alipay/alipay-api.html">
            
                    
                    支付宝API字典
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="./">
            
                <a href="./">
            
                    
                    微信支付
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.3.1" data-path="wxapi.html">
            
                <a href="wxapi.html">
            
                    
                    微信公用API
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.7.3.2" data-path="allapi.html">
            
                <a href="allapi.html">
            
                    
                    微信支付API接口
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3.3" data-path="micropay.html">
            
                <a href="micropay.html">
            
                    
                    微信刷卡支付
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3.4" data-path="wechatPay.html">
            
                <a href="wechatPay.html">
            
                    
                    微信公众号支付
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3.5" data-path="qrPay.html">
            
                <a href="qrPay.html">
            
                    
                    微信扫码支付
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3.6" data-path="appPay.html">
            
                <a href="appPay.html">
            
                    
                    微信APP支付
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3.7" data-path="H5.html">
            
                <a href="H5.html">
            
                    
                    微信H5支付
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3.8" data-path="wxapp.html">
            
                <a href="wxapp.html">
            
                    
                    微信小程序支付
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3.9" data-path="redpack.html">
            
                <a href="redpack.html">
            
                    
                    微信现金红包
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3.10" data-path="transfers.html">
            
                <a href="transfers.html">
            
                    
                    微信企业付款
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3.11" data-path="refund.html">
            
                <a href="refund.html">
            
                    
                    微信退款
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3.12" data-path="wxpay-notify.html">
            
                <a href="wxpay-notify.html">
            
                    
                    服务端异步通知
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../../.." >微信支付API接口</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h3 id="&#x5FAE;&#x4FE1;&#x652F;&#x4ED8;&#x76F8;&#x5173;&#x7684;&#x63A5;&#x53E3;">&#x5FAE;&#x4FE1;&#x652F;&#x4ED8;&#x76F8;&#x5173;&#x7684;&#x63A5;&#x53E3;</h3>
<blockquote>
<p>&#x666E;&#x901A;&#x5546;&#x6237;&#x6A21;&#x5F0F;&#x4E0E;&#x5546;&#x6237;&#x6A21;&#x5F0F;&#x4E0B;&#x652F;&#x4ED8;&#x63A5;&#x53E3;URL&#x90FD;&#x662F;&#x76F8;&#x540C;&#x7684;&#x53EA;&#x662F;&#x90E8;&#x5206;&#x8BF7;&#x6C42;&#x53C2;&#x6570;&#x4E0D;&#x540C;&#x3002;IJPay&#x4E2D;&#x5FAE;&#x4FE1;&#x652F;&#x4ED8;SDK&#x521D;&#x59CB;&#x5316;&#x4E0E;&#x652F;&#x4ED8;&#x5B9D;&#x521D;&#x59CB;&#x5316;&#x6A21;&#x5F0F;&#x4E00;&#x81F4;&#xFF0C;&#x8BF7;&#x53C2;&#x8003;IJPay&#x652F;&#x4ED8;&#x521D;&#x59CB;&#x5316;&#x3002;&#x5FAE;&#x4FE1;&#x652F;&#x4ED8;&#x521D;&#x59CB;&#x5316;&#x662F;&#x8BBE;&#x7F6E;&#x4E00;&#x4E9B;&#x5E38;&#x91CF;(appId&#x3001;mch_id&#x3001;partnerKey&#x3001;PayMode&#x7B49;)&#x5230;Map&#x4E2D;&#x907F;&#x514D;&#x540E;&#x9762;&#x63A5;&#x53E3;&#x8BF7;&#x6C42;&#x65F6;&#x5199;&#x8FC7;&#x591A;&#x5197;&#x4EE3;&#x7801;&#x3002;</p>
</blockquote>
<pre><code>public class WxPayApi {
    // &#x7EDF;&#x4E00;&#x4E0B;&#x5355;&#x63A5;&#x53E3;
    private static final String UNIFIEDORDER_URL = &quot;https://api.mch.weixin.qq.com/pay/unifiedorder&quot;;
    // &#x8BA2;&#x5355;&#x67E5;&#x8BE2;
    private static final String ORDERQUERY_URL = &quot;https://api.mch.weixin.qq.com/pay/orderquery&quot;;
    // &#x5173;&#x95ED;&#x8BA2;&#x5355;
    private static final String CLOSEORDER_URL = &quot;https://api.mch.weixin.qq.com/pay/closeorder&quot;;
    // &#x64A4;&#x9500;&#x8BA2;&#x5355;
    private static final String REVERSE_URL = &quot;https://api.mch.weixin.qq.com/secapi/pay/reverse&quot;;
    // &#x7533;&#x8BF7;&#x9000;&#x6B3E;
    private static final String REFUND_URL = &quot;https://api.mch.weixin.qq.com/secapi/pay/refund&quot;;
    // &#x67E5;&#x8BE2;&#x9000;&#x6B3E;
    private static final String REFUNDQUERY_URL = &quot;https://api.mch.weixin.qq.com/pay/refundquery&quot;;
    // &#x4E0B;&#x8F7D;&#x5BF9;&#x8D26;&#x5355;
    private static final String DOWNLOADBILLY_URL = &quot;https://api.mch.weixin.qq.com/pay/downloadbill&quot;;
    // &#x4EA4;&#x6613;&#x4FDD;&#x969C;
    private static final String REPORT_URL = &quot;https://api.mch.weixin.qq.com/payitil/report&quot;;
    // &#x8F6C;&#x6362;&#x77ED;&#x94FE;&#x63A5;
    private static final String SHORT_URL = &quot;https://api.mch.weixin.qq.com/tools/shorturl&quot;;
    // &#x6388;&#x6743;&#x7801;&#x67E5;&#x8BE2;openId&#x63A5;&#x53E3;
    private static final String AUTHCODETOOPENID_URL = &quot;https://api.mch.weixin.qq.com/tools/authcodetoopenid&quot;;
    // &#x5237;&#x5361;&#x652F;&#x4ED8;
    private static final String MICROPAY_URL = &quot;https://api.mch.weixin.qq.com/pay/micropay&quot;;
    // &#x4F01;&#x4E1A;&#x4ED8;&#x6B3E;
    private static final String TRANSFERS_URL = &quot;https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers&quot;;
    // &#x67E5;&#x8BE2;&#x4F01;&#x4E1A;&#x4ED8;&#x6B3E;
    private static final String GETTRANSFERINFO_URL = &quot;https://api.mch.weixin.qq.com/mmpaymkttransfers/gettransferinfo&quot;;
    // &#x7533;&#x8BF7;&#x7B7E;&#x7EA6;
    private static final String ENTRUSTWEB_URL = &quot;https://api.mch.weixin.qq.com/papay/entrustweb&quot;;
    // &#x652F;&#x4ED8;&#x4E2D;&#x7B7E;&#x7EA6;&#x63A5;&#x53E3;
    private static final String CONTRACTORDER_URL = &quot;https://api.mch.weixin.qq.com/pay/contractorder&quot;;
    // &#x67E5;&#x8BE2;&#x7B7E;&#x7EA6;&#x5173;&#x7CFB;
    private static final String QUERYCONTRACT_URL = &quot;https://api.mch.weixin.qq.com/papay/querycontract&quot;;
    // &#x7533;&#x8BF7;&#x6263;&#x6B3E;
    private static final String PAPPAYAPPLY_URL = &quot;https://api.mch.weixin.qq.com/pay/pappayapply&quot;;
    // &#x7533;&#x8BF7;&#x89E3;&#x7EA6;
    private static final String DELETECONTRACT_URL = &quot;https://api.mch.weixin.qq.com/papay/deletecontract&quot;;
    // &#x67E5;&#x8BE2;&#x7B7E;&#x7EA6;&#x5173;&#x7CFB;&#x5BF9;&#x8D26;&#x5355;
    private static final String CONTRACTBILL_URL = &quot;https://api.mch.weixin.qq.com/papay/contractbill&quot;;
    // &#x4EE3;&#x6263;&#x67E5;&#x8BE2;&#x8BA2;&#x5355;
    private static final String PAPORDERQUERYL_URL = &quot;https://api.mch.weixin.qq.com/pay/paporderquery&quot;;

    // &#x83B7;&#x53D6;&#x6C99;&#x7BB1;&#x79D8;&#x94A5;
    private static final String GETSINGKEY = &quot;https://api.mch.weixin.qq.com/sandboxnew/pay/getsignkey&quot;;
    // &#x7EDF;&#x4E00;&#x4E0B;&#x5355;&#x63A5;&#x53E3;
    private static final String UNIFIEDORDER_SANDBOXNEW_URL = &quot;https://api.mch.weixin.qq.com/sandboxnew/pay/unifiedorder&quot;;
    // &#x5237;&#x5361;&#x652F;&#x4ED8;
    private static final String MICROPAY_SANDBOXNEW_RUL = &quot;https://api.mch.weixin.qq.com/sandboxnew/pay/micropay&quot;;
    // &#x8BA2;&#x5355;&#x67E5;&#x8BE2;
    private static final String ORDERQUERY_SANDBOXNEW_URL = &quot;https://api.mch.weixin.qq.com/sandboxnew/pay/orderquery&quot;;
    // &#x7533;&#x8BF7;&#x9000;&#x6B3E;
    private static final String REFUND_SANDBOXNEW_URL = &quot;https://api.mch.weixin.qq.com/sandboxnew/secapi/pay/refund&quot;;
    // &#x67E5;&#x8BE2;&#x9000;&#x6B3E;
    private static final String REFUNDQUERY_SANDBOXNEW_URL = &quot;https://api.mch.weixin.qq.com/sandboxnew/pay/refundquery&quot;;
    // &#x4E0B;&#x8F7D;&#x5BF9;&#x8D26;&#x5355;
    private static final String DOWNLOADBILLY_SANDBOXNEW_URL = &quot;https://api.mch.weixin.qq.com/sandboxnew/pay/downloadbill&quot;;

    private WxPayApi() {
    }

    /**
     * &#x4EA4;&#x6613;&#x7C7B;&#x578B;&#x679A;&#x4E3E; &#x7EDF;&#x4E00;&#x4E0B;&#x5355;&#x63A5;&#x53E3;trade_type&#x7684;&#x4F20;&#x53C2;&#x53EF;&#x53C2;&#x8003;&#x8FD9;&#x91CC; JSAPI--&#x516C;&#x4F17;&#x53F7;&#x652F;&#x4ED8;&#x3001;&#x5C0F;&#x7A0B;&#x5E8F;&#x652F;&#x4ED8; NATIVE--&#x539F;&#x751F;&#x626B;&#x7801;&#x652F;&#x4ED8; APP--APP&#x652F;&#x4ED8;
     * MWEB--WAP&#x652F;&#x4ED8; MICROPAY--&#x5237;&#x5361;&#x652F;&#x4ED8;,&#x5237;&#x5361;&#x652F;&#x4ED8;&#x6709;&#x5355;&#x72EC;&#x7684;&#x652F;&#x4ED8;&#x63A5;&#x53E3;&#xFF0C;&#x4E0D;&#x8C03;&#x7528;&#x7EDF;&#x4E00;&#x4E0B;&#x5355;&#x63A5;&#x53E3;
     */
    public static enum TradeType {
        JSAPI, NATIVE, APP, WAP, MICROPAY, MWEB ,PAP
    }

    /**
     * &#x83B7;&#x53D6;&#x9A8C;&#x7B7E;&#x79D8;&#x94A5;API
     * 
     * @param mch_id
     *            &#x5546;&#x6237;&#x53F7;
     * @param partnerKey
     *            &#x5BC6;&#x94A5;
     * @return {String}
     */
    public static String getsignkey(String mch_id, String partnerKey) {
        Map&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
        String nonce_str = String.valueOf(System.currentTimeMillis());
        map.put(&quot;mch_id&quot;, mch_id);
        map.put(&quot;nonce_str&quot;, nonce_str);
        map.put(&quot;sign&quot;, PaymentKit.createSign(map, partnerKey));
        return doPost(GETSINGKEY, map);
    }

    /**
     * &#x7EDF;&#x4E00;&#x4E0B;&#x5355;
     * &#x670D;&#x52A1;&#x5546;&#x6A21;&#x5F0F;&#x63A5;&#x5165;&#x6587;&#x6863;:https://pay.weixin.qq.com/wiki/doc/api/native_sl.php?chapter=9_1
     * &#x5546;&#x6237;&#x6A21;&#x5F0F;&#x63A5;&#x5165;&#x6587;&#x6863;:https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=9_1
     * 
     * @param isSandbox
     *            &#x662F;&#x5426;&#x662F;&#x6C99;&#x76D2;&#x73AF;&#x5883;
     * @param params
     * @return {String}
     */
    public static String pushOrder(boolean isSandbox, Map&lt;String, String&gt; params) {
        if (isSandbox)
            return doPost(UNIFIEDORDER_SANDBOXNEW_URL, params);
        return doPost(UNIFIEDORDER_URL, params);
    }

    /**
     * &#x8BA2;&#x5355;&#x67E5;&#x8BE2;
     * &#x670D;&#x52A1;&#x5546;&#x6A21;&#x5F0F;&#x63A5;&#x5165;&#x6587;&#x6863;:https://pay.weixin.qq.com/wiki/doc/api/micropay_sl.php?chapter=9_2
     * &#x5546;&#x6237;&#x6A21;&#x5F0F;&#x63A5;&#x5165;&#x6587;&#x6863;:https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_2
     * 
     * @param isSandbox
     *            &#x662F;&#x5426;&#x662F;&#x6C99;&#x76D2;&#x73AF;&#x5883;
     * @param params
     *            &#x8BF7;&#x6C42;&#x53C2;&#x6570;
     * @return {String}
     */
    public static String orderQuery(boolean isSandbox, Map&lt;String, String&gt; params) {
        if (isSandbox)
            return doPost(ORDERQUERY_SANDBOXNEW_URL, params);
        return doPost(ORDERQUERY_URL, params);
    }

    /**
     * &#x5173;&#x95ED;&#x8BA2;&#x5355;
     * &#x670D;&#x52A1;&#x5546;&#x6A21;&#x5F0F;&#x63A5;&#x5165;&#x6587;&#x6863;:https://pay.weixin.qq.com/wiki/doc/api/jsapi_sl.php?chapter=9_3
     * &#x5546;&#x6237;&#x6A21;&#x5F0F;&#x63A5;&#x5165;&#x6587;&#x6863;:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_3
     * 
     * @param params
     * @return {String}
     */
    public static String closeOrder(Map&lt;String, String&gt; params) {
        return doPost(CLOSEORDER_URL, params);
    }

    /**
     * &#x64A4;&#x9500;&#x8BA2;&#x5355;
     * &#x670D;&#x52A1;&#x5546;&#x6A21;&#x5F0F;&#x63A5;&#x5165;&#x6587;&#x6863;:https://pay.weixin.qq.com/wiki/doc/api/micropay_sl.php?chapter=9_11&amp;index=3
     * &#x5546;&#x6237;&#x6A21;&#x5F0F;&#x63A5;&#x5165;&#x6587;&#x6863;:https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_11&amp;index=3
     * 
     * @param params
     *            &#x8BF7;&#x6C42;&#x53C2;&#x6570;
     * @param certPath
     *            &#x8BC1;&#x4E66;&#x6587;&#x4EF6;&#x76EE;&#x5F55;
     * @param certPass
     *            &#x8BC1;&#x4E66;&#x5BC6;&#x7801;
     * @return {String}
     */
    public static String orderReverse(Map&lt;String, String&gt; params, String certPath, String certPass) {
        return doPostSSL(REVERSE_URL, params, certPath, certPass);
    }

    /**
     * &#x7533;&#x8BF7;&#x9000;&#x6B3E;
     * &#x670D;&#x52A1;&#x5546;&#x6A21;&#x5F0F;&#x63A5;&#x5165;&#x6587;&#x6863;:https://pay.weixin.qq.com/wiki/doc/api/micropay_sl.php?chapter=9_4
     * &#x5546;&#x6237;&#x6A21;&#x5F0F;&#x63A5;&#x5165;&#x6587;&#x6863;:https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_4
     * 
     * @param isSandbox
     *            &#x662F;&#x5426;&#x662F;&#x6C99;&#x76D2;&#x73AF;&#x5883;
     * @param params
     *            &#x8BF7;&#x6C42;&#x53C2;&#x6570;
     * @param certPath
     *            &#x8BC1;&#x4E66;&#x6587;&#x4EF6;&#x76EE;&#x5F55;
     * @param certPass
     *            &#x8BC1;&#x4E66;&#x5BC6;&#x7801;
     * @return {String}
     */
    public static String orderRefund(boolean isSandbox, Map&lt;String, String&gt; params, String certPath, String certPass) {
        if (isSandbox)
            return doPostSSL(REFUND_SANDBOXNEW_URL, params, certPath, certPass);
        return doPostSSL(REFUND_URL, params, certPath, certPass);
    }

    /**
     * &#x67E5;&#x8BE2;&#x9000;&#x6B3E;
     * &#x670D;&#x52A1;&#x5546;&#x6A21;&#x5F0F;&#x63A5;&#x5165;&#x6587;&#x6863;:https://pay.weixin.qq.com/wiki/doc/api/micropay_sl.php?chapter=9_5
     * &#x5546;&#x6237;&#x6A21;&#x5F0F;&#x63A5;&#x5165;&#x6587;&#x6863;:https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_5
     * 
     * @param isSandbox
     *            &#x662F;&#x5426;&#x662F;&#x6C99;&#x76D2;&#x73AF;&#x5883;
     * @param params
     *            &#x8BF7;&#x6C42;&#x53C2;&#x6570;
     * @return {String}
     */
    public static String orderRefundQuery(boolean isSandbox, Map&lt;String, String&gt; params) {
        if (isSandbox)
            return doPost(REFUNDQUERY_SANDBOXNEW_URL, params);
        return doPost(REFUNDQUERY_URL, params);
    }

    /**
     * &#x4E0B;&#x8F7D;&#x5BF9;&#x8D26;&#x5355;
     * &#x670D;&#x52A1;&#x5546;&#x6A21;&#x5F0F;&#x63A5;&#x5165;&#x6587;&#x6863;:https://pay.weixin.qq.com/wiki/doc/api/micropay_sl.php?chapter=9_6
     * &#x5546;&#x6237;&#x6A21;&#x5F0F;&#x63A5;&#x5165;&#x6587;&#x6863;:https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_6
     * 
     * @param isSandbox
     *            &#x662F;&#x5426;&#x662F;&#x6C99;&#x76D2;&#x73AF;&#x5883;
     * @param params
     *            &#x8BF7;&#x6C42;&#x53C2;&#x6570;
     * @return {String}
     */
    public static String downloadBill(boolean isSandbox, Map&lt;String, String&gt; params) {
        if (isSandbox)
            return doPost(DOWNLOADBILLY_SANDBOXNEW_URL, params);
        return doPost(DOWNLOADBILLY_URL, params);
    }

    /**
     * &#x4EA4;&#x6613;&#x4FDD;&#x969C;
     * &#x670D;&#x52A1;&#x5546;&#x6A21;&#x5F0F;&#x63A5;&#x5165;&#x6587;&#x6863;:https://pay.weixin.qq.com/wiki/doc/api/micropay_sl.php?chapter=9_14&amp;index=7
     * &#x5546;&#x6237;&#x6A21;&#x5F0F;&#x63A5;&#x5165;&#x6587;&#x6863;:https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_14&amp;index=7
     * 
     * @param params
     *            &#x8BF7;&#x6C42;&#x53C2;&#x6570;
     * @return {String}
     */
    public static String orderReport(Map&lt;String, String&gt; params) {
        return doPost(REPORT_URL, params);
    }

    /**
     * &#x8F6C;&#x6362;&#x77ED;&#x94FE;&#x63A5;
     * &#x670D;&#x52A1;&#x5546;&#x6A21;&#x5F0F;&#x63A5;&#x5165;&#x6587;&#x6863;:https://pay.weixin.qq.com/wiki/doc/api/micropay_sl.php?chapter=9_9&amp;index=8
     * &#x5546;&#x6237;&#x6A21;&#x5F0F;&#x63A5;&#x5165;&#x6587;&#x6863;:https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_9&amp;index=8
     * 
     * @param params
     *            &#x8BF7;&#x6C42;&#x53C2;&#x6570;
     * @return {String}
     */
    public static String toShortUrl(Map&lt;String, String&gt; params) {
        return doPost(SHORT_URL, params);
    }

    /**
     * &#x6388;&#x6743;&#x7801;&#x67E5;&#x8BE2;openId
     * &#x670D;&#x52A1;&#x5546;&#x6A21;&#x5F0F;&#x63A5;&#x5165;&#x6587;&#x6863;:https://pay.weixin.qq.com/wiki/doc/api/micropay_sl.php?chapter=9_12&amp;index=9
     * &#x5546;&#x6237;&#x6A21;&#x5F0F;&#x63A5;&#x5165;&#x6587;&#x6863;:
     * https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_13&amp;index=9
     * 
     * @param params
     *            &#x8BF7;&#x6C42;&#x53C2;&#x6570;
     * @return {String}
     */
    public static String authCodeToOpenid(Map&lt;String, String&gt; params) {
        return doPost(AUTHCODETOOPENID_URL, params);
    }

    /**
     * &#x5237;&#x5361;&#x652F;&#x4ED8;
     * &#x670D;&#x52A1;&#x5546;&#x6A21;&#x5F0F;&#x63A5;&#x5165;&#x6587;&#x6863;:https://pay.weixin.qq.com/wiki/doc/api/micropay_sl.php?chapter=9_10&amp;index=1
     * &#x5546;&#x6237;&#x6A21;&#x5F0F;&#x63A5;&#x5165;&#x6587;&#x6863;:
     * https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_10&amp;index=1
     * 
     * @param isSandbox
     *            &#x662F;&#x5426;&#x662F;&#x6C99;&#x76D2;&#x73AF;&#x5883;
     * @param params
     *            &#x8BF7;&#x6C42;&#x53C2;&#x6570;
     * @return {String}
     */
    public static String micropay(boolean isSandbox, Map&lt;String, String&gt; params) {
        if (isSandbox)
            return WxPayApi.doPost(MICROPAY_SANDBOXNEW_RUL, params);
        return WxPayApi.doPost(MICROPAY_URL, params);
    }

    /**
     * &#x4F01;&#x4E1A;&#x4ED8;&#x6B3E;
     * 
     * @param params
     *            &#x8BF7;&#x6C42;&#x53C2;&#x6570;
     * @param certPath
     *            &#x8BC1;&#x4E66;&#x6587;&#x4EF6;&#x76EE;&#x5F55;
     * @param certPassword
     *            &#x8BC1;&#x4E66;&#x5BC6;&#x7801;
     * @return {String}
     */
    public static String transfers(Map&lt;String, String&gt; params, String certPath, String certPassword) {
        return WxPayApi.doPostSSL(TRANSFERS_URL, params, certPath, certPassword);
    }

    /**
     * &#x67E5;&#x8BE2;&#x4F01;&#x4E1A;&#x4ED8;&#x6B3E;
     * 
     * @param params
     *            &#x8BF7;&#x6C42;&#x53C2;&#x6570;
     * @param certPath
     *            &#x8BC1;&#x4E66;&#x6587;&#x4EF6;&#x76EE;&#x5F55;
     * @param certPassword
     *            &#x8BC1;&#x4E66;&#x5BC6;&#x7801;
     * @return {String}
     */
    public static String getTransferInfo(Map&lt;String, String&gt; params, String certPath, String certPassword) {
        return WxPayApi.doPostSSL(GETTRANSFERINFO_URL, params, certPath, certPassword);
    }

    /**
     * &#x5546;&#x6237;&#x6A21;&#x5F0F;&#x4E0B; &#x626B;&#x7801;&#x6A21;&#x5F0F;&#x4E00;&#x4E4B;&#x751F;&#x6210;&#x4E8C;&#x7EF4;&#x7801;
     * 
     * @param appid
     * @param mch_id
     * @param product_id
     * @param partnerKey
     * @param isToShortUrl
     *            &#x662F;&#x5426;&#x8F6C;&#x5316;&#x4E3A;&#x77ED;&#x8FDE;&#x63A5;
     * @return {String}
     */
    public static String getCodeUrl(String appid, String mch_id, String product_id, String partnerKey,
            boolean isToShortUrl) {
        String url = &quot;weixin://wxpay/bizpayurl?sign=XXXXX&amp;appid=XXXXX&amp;mch_id=XXXXX&amp;product_id=XXXXX&amp;time_stamp=XXXXX&amp;nonce_str=XXXXX&quot;;
        String timeStamp = Long.toString(System.currentTimeMillis() / 1000);
        String nonceStr = Long.toString(System.currentTimeMillis());
        Map&lt;String, String&gt; packageParams = new HashMap&lt;String, String&gt;();
        packageParams.put(&quot;appid&quot;, appid);
        packageParams.put(&quot;mch_id&quot;, mch_id);
        packageParams.put(&quot;product_id&quot;, product_id);
        packageParams.put(&quot;time_stamp&quot;, timeStamp);
        packageParams.put(&quot;nonce_str&quot;, nonceStr);
        String packageSign = PaymentKit.createSign(packageParams, partnerKey);
        String qrCodeUrl = PaymentKit.replace(url, &quot;XXXXX&quot;, packageSign, appid, mch_id, product_id, timeStamp,
                nonceStr);
        if (isToShortUrl) {
            String shortResult = WxPayApi
                    .toShortUrl(PaymentKit.buildShortUrlParasMap(appid, null, mch_id, null, qrCodeUrl, partnerKey));
            Map&lt;String, String&gt; shortMap = PaymentKit.xmlToMap(shortResult);
            String return_code = shortMap.get(&quot;return_code&quot;);
            if (PaymentKit.codeIsOK(return_code)) {
                String result_code = shortMap.get(&quot;result_code&quot;);
                if (PaymentKit.codeIsOK(result_code)) {
                    qrCodeUrl = shortMap.get(&quot;short_url&quot;);
                }
            }
        }

        return qrCodeUrl;
    }

    /**
     * &#x7533;&#x8BF7;&#x7B7E;&#x7EA6; https://pay.weixin.qq.com/wiki/doc/api/pap.php?chapter=18_1&amp;index=1
     * 
     * @param params
     *            &#x8BF7;&#x6C42;&#x53C2;&#x6570;
     * @return {String}
     */
    public static String entrustweb(Map&lt;String, String&gt; params) {
        return doGet(ENTRUSTWEB_URL, params);
    }

    /**
     * &#x652F;&#x4ED8;&#x4E2D;&#x7B7E;&#x7EA6; https://pay.weixin.qq.com/wiki/doc/api/pap.php?chapter=18_13&amp;index=2
     * 
     * @param params
     *            &#x8BF7;&#x6C42;&#x53C2;&#x6570;
     * @return {String}
     */
    public static String contractorder(Map&lt;String, String&gt; params) {
        return doPost(CONTRACTORDER_URL, params);
    }

    /**
     * &#x67E5;&#x8BE2;&#x7B7E;&#x7EA6;&#x5173;&#x7CFB; https://pay.weixin.qq.com/wiki/doc/api/pap.php?chapter=18_2&amp;index=3
     * 
     * @param params
     *            &#x8BF7;&#x6C42;&#x53C2;&#x6570;
     * @return {String}
     */
    public static String querycontract(Map&lt;String, String&gt; params) {
        return doPost(QUERYCONTRACT_URL, params);
    }

    /**
     * &#x7533;&#x8BF7;&#x6263;&#x6B3E;
     * 
     * @param params
     *            &#x8BF7;&#x6C42;&#x53C2;&#x6570;
     * @return {String}
     */
    public static String pappayapply(Map&lt;String, String&gt; params) {
        return doPost(PAPPAYAPPLY_URL, params);
    }

    /**
     * &#x7533;&#x8BF7;&#x89E3;&#x7EA6;
     * 
     * @param params
     *            &#x8BF7;&#x6C42;&#x53C2;&#x6570;
     * @return {String}
     */
    public static String deletecontract(Map&lt;String, String&gt; params) {
        return doPost(DELETECONTRACT_URL, params);
    }

    /**
     * &#x67E5;&#x8BE2;&#x7B7E;&#x7EA6;&#x5173;&#x7CFB;&#x5BF9;&#x8D26;&#x5355;
     * 
     * @param params
     *            &#x8BF7;&#x6C42;&#x53C2;&#x6570;
     * @return {String}
     */
    public static String contractbill(Map&lt;String, String&gt; params) {
        return doPost(CONTRACTBILL_URL, params);
    }

    /**
     * &#x4EE3;&#x6263;&#x8BA2;&#x5355;&#x67E5;&#x8BE2;
     * 
     * @param params
     *            &#x8BF7;&#x6C42;&#x53C2;&#x6570;
     * @return {String}
     */
    public static String paporderquery(Map&lt;String, String&gt; params) {
        return doPost(PAPORDERQUERYL_URL, params);
    }

    public static String doGet(String url, Map&lt;String, String&gt; params) {
        return HttpUtils.get(url, params);
    }

    public static String doPost(String url, Map&lt;String, String&gt; params) {
        return HttpUtils.post(url, PaymentKit.toXml(params));
    }

    public static String doPostSSL(String url, Map&lt;String, String&gt; params, String certPath, String certPass) {
        return HttpUtils.postSSL(url, PaymentKit.toXml(params), certPath, certPass);
    }

}
</code></pre>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="wxapi.html" class="navigation navigation-prev " aria-label="Previous page: 微信公用API">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="micropay.html" class="navigation navigation-next " aria-label="Next page: 微信刷卡支付">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"微信支付API接口","level":"1.7.3.2","depth":3,"next":{"title":"微信刷卡支付","level":"1.7.3.3","depth":3,"path":"doc/ijpay/wxpay/micropay.md","ref":"doc/ijpay/wxpay/micropay.md","articles":[]},"previous":{"title":"微信公用API","level":"1.7.3.1","depth":3,"path":"doc/ijpay/wxpay/wxapi.md","ref":"doc/ijpay/wxpay/wxapi.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"doc/ijpay/wxpay/allapi.md","mtime":"2018-09-27T15:07:51.337Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-09-28T14:55:50.579Z"},"basePath":"../../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../../gitbook/gitbook.js"></script>
    <script src="../../../gitbook/theme.js"></script>
    
        
        <script src="../../../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

